package com.yerbamateprimer.advice.impl;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.google.common.base.Preconditions;
import com.yerbamateprimer.advice.SingleReceptorAdvice;
import com.yerbamateprimer.model.User;

/**
 * This class models an advice
 * to ask a user, deliver the 
 * mate to another user.
 * 
 * @author Matias Liwski
 * @version 1.0
 */
public class DeliverTheMateAdvice implements SingleReceptorAdvice{
	private static final long serialVersionUID = -1671800876115393323L;
	private User adviceReceptor;
	private User mateReceptor;

	/**
	 * @param adviceReceptor The receptor of the advice.
	 * @param mateReceptor The receptor of the mate.
	 */
	public DeliverTheMateAdvice(User adviceReceptor, User mateReceptor) {
		setAdviceReceptor(adviceReceptor);
		setMateReceptor(mateReceptor);
	}

	/* (non-Javadoc)
	 * @see com.yerbamateprimer.advice.SingleReceptorAdvice#setReceptor(com.yerbamateprimer.model.User)
	 */
	@Override
	public void setAdviceReceptor(User adviceReceptor) {
		Preconditions.checkArgument(adviceReceptor != null, "This advice need a receptor.");
		this.adviceReceptor = adviceReceptor;
	}

	/* (non-Javadoc)
	 * @see com.yerbamateprimer.advice.SingleReceptorAdvice#getReceptor()
	 */
	@Override
	public User getAdviceReceptor() {
		return this.adviceReceptor;
	}

	/**
	 * @param mateReceptor The receptor of the mate to set.
	 */
	public void setMateReceptor(User mateReceptor) {
		Preconditions.checkArgument(mateReceptor != null, "This advice need a receiving user.");		
		this.mateReceptor = mateReceptor;
	}

	/**
	 * @return The receptor of the mate.
	 */
	public User getMateReceptor() {
		return mateReceptor;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE, false, false);
	}
}